<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <h1>工程首页</h1>
    <a href="/reg.html">注册</a>
    <a href="/login.html">登录</a>
    <h2>{{info}}</h2>
</div>

<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>

<script>
    let v=new Vue({
        el:"body>div",
        data:{
            user:{},
            info:""
        },
        created:function () {
            axios.get("/currentUser").then(function (response) {
                v.user=response.data;
                console.log("服务器返回内容："+response.data);
                if (response.data==""){//代表还未登录
                    v.info="请先登陆！";
                }else {//代表登录过
                    v.info="欢迎"+v.user.nick;
                }
            })
        }
    })
</script>

</body>
</html>